<?php
require_once ("db/db_connector.php");
require_once ("db/db_tag.php");

// Database Access Begins ---------------------------------------- //
$con = get_db_con();
$_POST['name'];
if (tag_exists($con, $_POST)) {
	$tag_list=get_tag_paradise_name($con,$_POST);
	$tag;
	foreach($tag_list as $tag){
		$rating=$tag['rating'];
		$rating=intval($rating);
		$rating++;
		$tag['rating']=$rating;
		
		update_tag($con,$tag);	
	}

} else {
	$_POST['rating']=1;
	insert_tag($con, $_POST);
}
$id = $_POST['paradise_id'];
header("Location: paradise.php?id=$id");

close_db_con();
// Database Access Ends ------------------------------------------ //
